package com.jeasonzhao.report.vml.chart.data;

import com.jeasonzhao.report.vml.chart.CommonStyle;


public class Range extends CommonStyle
{
    private Element begin;
    private Element end;
    public Range()
    {
        super();
    }

    public Range(double min,double max)
    {
        super();
        begin = new Element(Math.min(min,max));
        end = new Element(Math.max(min,max));
    }

    public boolean isResideIn(Range r)
    {
        return null != r && r.begin != null && r.end != null &&
            this.begin != null && this.end != null &&
            this.begin.getValue() >= r.begin.getValue() &&
            this.begin.getValue() <= r.end.getValue() &&
            this.end.getValue() >= r.begin.getValue() &&
            this.end.getValue() <= r.end.getValue();
    }

    public boolean isContains(Element ele)
    {
        return null != begin && null != end && ele != null &&
            ele.getValue() >= begin.getValue() &&
            ele.getValue() <= end.getValue();
    }

    public boolean isContains(Range r)
    {
        return null != r && r.isResideIn(this);
    }

    public boolean isContains(double ele)
    {
        return null != begin && null != end &&
            ele >= begin.getValue() &&
            ele <= end.getValue();
    }

    public void setBegin(Element begin)
    {
        this.begin = begin;
    }

    public void setEnd(Element end)
    {
        this.end = end;
    }

    public Element getBegin()
    {
        return begin;
    }

    public Element getEnd()
    {
        return end;
    }
}
